package com.tarena.lbs.basic.web.mapper;

import com.tarena.lbs.pojo.basic.bo.UserBO;
import com.tarena.lbs.pojo.basic.dos.UserDO;
import com.tarena.lbs.pojo.basic.dos.UserGroupDO;
import com.tarena.lbs.pojo.basic.dos.UserTagsDO;
import com.tarena.lbs.pojo.basic.param.UserTagsParam;
import com.tarena.lbs.pojo.basic.query.UserGroupQuery;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface UserMapper {
    @Insert("INSERT INTO lbs_user (\n" +
            "        user_name,\n" +
            "        password,\n" +
            "        nick_name,\n" +
            "        ip_address,\n" +
            "        reg_time,\n" +
            "        last_log_time,\n" +
            "        introduction,\n" +
            "        phone,\n" +
            "        provider_type,\n" +
            "        status,\n" +
            "        union_id,\n" +
            "        user_image\n" +
            "    ) VALUES (\n" +
            "        #{userName,jdbcType=VARCHAR},\n" +
            "        #{password,jdbcType=VARCHAR},\n" +
            "        #{nickName,jdbcType=VARCHAR},\n" +
            "        #{ipAddress,jdbcType=VARCHAR},\n" +
            "        #{regTime,jdbcType=TIMESTAMP},\n" +
            "        #{lastLogTime,jdbcType=TIMESTAMP},\n" +
            "        #{introduction,jdbcType=VARCHAR},\n" +
            "        #{phone,jdbcType=CHAR},\n" +
            "        #{providerType,jdbcType=TINYINT},\n" +
            "        #{status,jdbcType=TINYINT},\n" +
            "        #{unionId,jdbcType=VARCHAR},\n" +
            "        #{userImage,jdbcType=VARCHAR}\n" +
            "    )")
    void saveUser(UserDO userDO);
    @Select("select * from lbs_user where phone=#{phone}")
    UserDO selectUserByPhone(String phone);

    @Select("select * from lbs_user where id=#{userId}")
    UserDO selectUserById(Integer userId);


    void bindUsertags(List<UserTagsDO> userTagsDOS);

    @Delete("delete from lbs_user_tags where user_id=#{userId}")
    void deleteUserTagsById(Integer userId);

    @Update("update lbs_user set status=#{status} where id=#{id}")
    void updateUserStatus(UserDO userDO);

}
